import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;


public class GamePanel extends JPanel {
	
	 
	private static final long serialVersionUID = 1L;
	public Color[] cores = {Color.white,Color.red,Color.blue,Color.green,Color.yellow,Color.orange,
							Color.GRAY,Color.cyan,Color.magenta,Color.darkGray, Color.LIGHT_GRAY,
							Color.PINK, new Color(159,95,159), new Color(92,64,51),new Color(47,79,47),new Color(235,199,158)};
	public flowfree fl;
	public GamePanel(flowfree fl) {
		
		this.fl=fl;
	}
	
	public void paintComponent(Graphics g)
    {       
		super.paintComponent(g);
		int x =0;
		int y=0;
		int width=50;
		 		for(int i = 0; i< fl.matrix.length;i++)
		{
			for(int j=0;j<fl.matrix[i].length;j++)
			{
				
				g.setColor(cores[fl.matrix[i][j]%100]);
			 
				g.fillRect(x, y, width, width);
				g.setColor(Color.black);
				if(fl.matrix[i][j]>100)
				{
					g.drawOval(x+width/4+width/8, y+width/4+width/8, width/4, width/4);
					g.fillOval(x+width/4+width/8, y+width/4+width/8, width/4, width/4);
					
				}
				g.drawLine(x+width, y,x+width, y+width);
				g.drawLine(x, y,x, y+width);
				g.drawLine(x, y,x+width, y);
				g.drawLine(x, y+width,x+width, y+width);
				x+=width;
				
				//g.drawLine(x+width, y, x, y+width);
			}
			x=0;
			y+=width;
		}
		 
		repaint();
    
    } 
	public void update(Graphics g){
		paint(g);
	}

}
